<?php
/*========================================= JooSam =========================================/
/																							/
/	Extention:		JooSam																	/
/	Created by:		Broadcastweb.eu - Paules												/
/	Site:			http://www.broadcastweb.eu												/
/	Email:			support@broadcastweb.eu													/
/	Copyright:		2011 - 2012 (c) Broadcastweb.eu											/
/	License:		CC BY-NC-ND 3.0 ~ http://creativecommons.org/licenses/by-nc-nd/3.0/		/
/	File Version:	0003																	/
/																							/
/========================================== JooSam ========================================*/
// Joomla security
defined('_JEXEC') or die;
jimport('joomla.application.component.controlleradmin');

// Controller Samsong view
class JooSamControllerSamadmin extends JControllerAdmin{
	protected $text_prefix = 'Samadmin';

	public function playreset(){
		
		require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joosam' . DS . 'helpers' . DS . 'helper.samdb.php';
		$server = JoosamHelper::currSrvEdit();
		$serid = $server['id'];
		
		$data = SamdbHelper::samdb('resetPlayCount', $serid);
		$error = $data['status'];
		$result = $data['data'];

		if($error == 'valid'){
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_RESSETTED_PLAYOUNT').$result;
			$this->setMessage($txt);
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
		else{
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_RBERROR').$result;
			$this->setMessage($txt, 'warning');
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
	}

	public function requestreset(){
		
		require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joosam' . DS . 'helpers' . DS . 'helper.samdb.php';
		$server = JoosamHelper::currSrvEdit();
		$serid = $server['id'];
		
		$data = SamdbHelper::samdb('resetRequestCount', $serid);
		$error = $data['status'];
		$result = $data['data'];

		if($error == 'valid'){
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_RESSETTED_REQUESTOUNT').$result;
			$this->setMessage($txt);
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
		else{
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_RBERROR').$result;
			$this->setMessage($txt, 'warning');
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
	}

	public function perferreset(){
		
		require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joosam' . DS . 'helpers' . DS . 'helper.samdb.php';
		$server = JoosamHelper::currSrvEdit();
		$serid = $server['id'];
		
		$data = SamdbHelper::samdb('resetPerfemCount', $serid);
		$error = $data['status'];
		$result = $data['data'];

		if($error == 'valid'){
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_RESSETTED_PREFOCOUNT').$result;
			$this->setMessage($txt);
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
		else{
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_RBERROR').$result;
			$this->setMessage($txt, 'warning');
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
	}

	public function delhistory(){
		
		require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joosam' . DS . 'helpers' . DS . 'helper.samdb.php';
		$server = JoosamHelper::currSrvEdit();
		$serid = $server['id'];
		
		$data = SamdbHelper::samdb('delFullHistory', $serid);
		$error = $data['status'];
		$result = $data['data'];

		if($error == 'valid'){
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_RESSETTED_HISTORYLIST').$result;
			$this->setMessage($txt);
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
		else{
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_RBERROR').$result;
			$this->setMessage($txt, 'warning');
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
	}

	public function delrequests(){
		
		require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joosam' . DS . 'helpers' . DS . 'helper.samdb.php';
		$server = JoosamHelper::currSrvEdit();
		$serid = $server['id'];
		
		$data = SamdbHelper::samdb('delFullReqlist', $serid);
		$error = $data['status'];
		$result = $data['data'];

		if($error == 'valid'){
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_RESSETTED_REQUESTLIST').$result;
			$this->setMessage($txt);
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
		else{
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_RBERROR').$result;
			$this->setMessage($txt, 'warning');
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
	}

	public function fixsongtype(){
		
		require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joosam' . DS . 'helpers' . DS . 'helper.samdb.php';
		$server = JoosamHelper::currSrvEdit();
		$serid = $server['id'];
		
		$data = SamdbHelper::samdb('fixSongTypeData', $serid);
		$error = $data['status'];
		$result = $data['data'];

		if($error == 'valid'){
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_SONGTYPES_TO_S').$result;
			$this->setMessage($txt);
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
		else{
			$txt = JText::_('COM_JOOSAM_SADMIN_CONT_RBERROR').$result;
			$this->setMessage($txt, 'warning');
			$this->setRedirect(JRoute::_('index.php?option=com_joosam&view=samadmin', false));
		}
	}
}